package com.bgds.sys.task;

import cn.hutool.core.collection.CollectionUtil;
import com.bgds.sys.common.pagevo.RollerVo;
import com.bgds.sys.common.utils.ResultUtil;
import com.bgds.sys.influx.service.InfluxService;
import com.bgds.sys.module.controller.BaseBaoxing;
import com.bgds.sys.module.entity.DeviceDynamicAttr;
import com.bgds.sys.module.entity.vo.PumpSocketVo;
import com.bgds.sys.module.service.IDeviceDynamicAttrService;
import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;


/**
 * @author Smiling
 * @description: TODO
 * @date 2021/5/24  22:37
 */
@Component
public class DiscalingPumpJob implements Job {
    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    @Autowired
    private BaseBaoxing baseBaoxing;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
        String deviceCode = dataMap.get("deviceCode").toString();
        String id = dataMap.get("id").toString();
        messagingTemplate.convertAndSendToUser(id, "/discaling_pump", new ResultUtil<>().setData(baseBaoxing.all(deviceCode)));
    }
}